﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Bifrost;

namespace CLIENT_EMR
{
    public partial class frmLogin : Form
    {
        public frmLogin()
        {
            InitializeComponent();                   
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            App.Ini();

            string url=App.Read_ConfigInfo("WebServerPath", "Url", Application.StartupPath + "\\Config.ini");
            //App.wc.Url = url;
            App.wc.Url = @"http://"+Encrypt.DecryptStr(url)+@"/WcfSvr/Service.svc";
            //App.wc.Url = "http://localhost:32862/Service.svc";
            lblVersion.Text = "当前版本：" + App.ProgrameVersion;
            pictureBox1.Refresh();
        }

        private void btnCancelx_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btnLoadx_Click(object sender, EventArgs e)
        {
          
            App.UserAccount = App.wc.GetLoginCurrentAccout(txtAccount.Text,
                txtPassword.Text);
            
            if (App.UserAccount == null)
             {
                 App.MsgWaring("用户或密码不正确！");
                 txtAccount.Text = "";
                 txtPassword.Text = "";
                 txtAccount.Focus();
                 return;
             }
             else {
                 this.Hide();
                 frmMain fc = new frmMain();
                 fc.Show();
                 // App.Msg("登录成功！");
             }
            
        }

        private void txtAccount_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                txtPassword.Focus();
            }
        }

        private void txtPassword_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                btnLoadx_Click(sender,e);
            }
        }

        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
   
       
        }
    }
}
